<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <textarea name="" id="txt" cols="50" rows="10"></textarea>
</body>
<script>
    // 要求在 textareea 中写代码, 并实时的执行该代码
    var txt = document.getElementById( 'txt' );

    txt.onkeyup = function () {
        // console.log( this.value );
        try {
            eval( this.value );
        } catch ( e ) {
            console.log( e );
        }
    };

</script>
</html>